﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Serialize.model
{
    [XmlRoot("product", Namespace = "https://heima.codeplex.com/")]
    public class Product
    {
        public Product()
        {

        }

        public Product(string name, string description)
        {
            this.ID = Guid.NewGuid();
            this.Name = name;
            this.Description = description;
        }
        // ElementName - 生成的 XML 元素的名称
        // Order - 序列化和反序列化的顺序
        [XmlElement("Unique", Order = 0)]
        public Guid ID { get; set; }

        [XmlElement(Order = 1)]
        public string Name { get; set; }

        [XmlElement(Order = 2)]
        public string Description { get; set; }

        public override string ToString()
        {
            return string.Format("产品ID：{0}\r\n产品名称：{1}\r\n产品描述：{2}", ID, Name, Description);
        }
    }
}
